/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - resource
// Copyright( c) 2014.  All Rights Reserved
//
// File:		AETexture.inl
// Author:		Gianluca Belardelli
// Date:		02/10/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AETEXTURE_INL_
#define _AETEXTURE_INL_

AE_FORCEINLINE AETextureType AETexture::GetTextureType( void ) const
{
	return static_cast<AETextureType>( m_cTextureType );
}

AE_FORCEINLINE AEINT32 AETexture::GetTextureWidth( void ) const
{
	return m_sSizeX;
}

AE_FORCEINLINE AEINT32 AETexture::GetTextureHeight( void ) const
{
	return m_sSizeY;
}

AE_FORCEINLINE AEINT32 AETexture::GetTextureDepth( void ) const
{
	return m_sDepth;
}

AE_FORCEINLINE AEINT32 AETexture::GetTextureColorDepth( void ) const
{
	return GetColorDepthFromTextureFormat( (AETextureFormat)m_cTextureFormat );
}

AE_FORCEINLINE AEINT32 AETexture::GetTextureColorDepthUncompressed( void ) const
{
	switch( m_cTextureFormat )
	{
		case DXT1:
		case DXT1A:
			return 24;

		case DXT3:
		case DXT5:
			return 32;
	}

	return GetColorDepthFromTextureFormat( (AETextureFormat)m_cTextureFormat );

}

AE_FORCEINLINE AETextureFormat AETexture::GetTextureFormat( void ) const
{
	return static_cast<AETextureFormat>( m_cTextureFormat );
}

AE_FORCEINLINE AEBOOL32 AETexture::IsHeightMap( void ) const
{
	return m_cTextureType == AETT_HEIGHTMAP16BPP;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsTexture2D( void ) const
{
	return m_cTextureType == AETT_TEXTURE2D;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsTexture3D( void ) const
{
	return m_cTextureType == AETT_TEXTURE3D;
}

#if defined(AE_SUPPORTS_2D_TEXTURE_ARRAYS)

AE_FORCEINLINE AEBOOL32 AETexture::IsTexture2DArray( void ) const
{
	return m_cTextureType == AETT_TEXTURE2DARRAY;
}

#endif

AE_FORCEINLINE AEBOOL32 AETexture::IsCubemap( void ) const
{
	return m_cTextureType == AETT_CUBEMAP;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsAnimated( void ) const
{
	return ( m_lpAnimInfo != NULL );
}

AE_FORCEINLINE AEINT32 AETexture::GetNumAnimPhases( void ) const
{
	if( m_lpAnimInfo )
		return m_lpAnimInfo->sNumFrames;

	return 0;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsCompressed( void ) const
{
	if( IsHeightMap() )
		return 0; ///< internal format is just 8/16/32bpp

	return IsFormatCompressed( GetTextureFormat() );
}

AE_FORCEINLINE AEINT32 AETexture::GetMipMapLevelCount( void ) const
{
	return m_cMipLevels;
}

AE_FORCEINLINE AEBOOL32 AETexture::HasMipMaps( void ) const
{
	return GetMipMapLevelCount() > 1;
}

AE_FORCEINLINE AETexture *AETexture::GetTextureAnimFrame( AEINT32 nFrameNum )
{
	AEASSERT( nFrameNum >= 0 && nFrameNum < m_lpAnimInfo->sNumFrames );
	return &m_lpAnimInfo->lpFrame[ nFrameNum ];
}

AE_FORCEINLINE AEBOOL32 AETexture::IsTexturePowerOfTwo( void ) const
{
	return ( AEMath::IsPowerOf2( m_sSizeX ) && AEMath::IsPowerOf2( m_sSizeY ) );
}

AE_FORCEINLINE AETextureManager *AETexture::GetParentTextureManager( void ) const
{
	//return (AETextureManager *)AEResource::GetParentManager();
	return 0L;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsUpsideDown( void ) const
{
	return m_bIsUpsideDown;
}

AE_FORCEINLINE void AETexture::EnableUnloading( void )
{
	SetResourceFlag( AERESOURCEFLAG_ALLOWUNLOAD );
}

AE_FORCEINLINE void AETexture::DisableUnloading( void )
{
	RemoveResourceFlag( AERESOURCEFLAG_ALLOWUNLOAD );
}

//////////////////////////////////////////////////
// Protected class methods
//////////////////////////////////////////////////
AE_FORCEINLINE void AETexture::SetUpsideDown( AEBOOL32 bStatus )
{
	m_bIsUpsideDown = bStatus;
}

AE_FORCEINLINE void AETexture::SetIsCreatedFromMemory( AEBOOL32 bStatus )
{
	m_bIsCreatedFromMemory = bStatus;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsCreatedFromMemory( void ) const
{
	return m_bIsCreatedFromMemory;
}

AE_FORCEINLINE AEBOOL32 AETexture::IsDestroyHandleOnLostDeviceEnabled( void ) const
{
	return m_bDestroyHandleOnLostDevice;
}

#endif // _AETEXTURE_INL_
